% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/country_date.R
\name{interpolate}
\alias{interpolate}
\title{Interpolation}
\usage{
interpolate(x)
}
\arguments{
\item{x}{Object to interpolate.}
}
\description{
S3 generic function that back fills an object if the last element
is the only non-missing observation. Otherwise, front filling by
carrying the last observation forward is done, similar to
\code{\link{locf}}. For DataFrames and Matrices, this is all done
column-wise.
}
\details{
The differences between \code{locf} and \code{interpolate}
    are frustratingly trivial; however, we need the
    \code{interpolate} functions in situations where the only
    observation is at the default date ("-12-31"), which should
    then represent the entire year.

    For example, when conforming multiple country-date level
    variables, missingness introduced by merging should be first
    interpolated before being expanded so as to better reflect the
    observation at the default date representing the entire year,
    rather than the previous year's default date observation being
    carried forward until "-12-30".
}
\examples{
df <- data.frame(x = c(1, NA, 2),
                 y = as.Date(c("1900-12-31", "1901-10-12", "1902-12-31")))

transform(df, x = interpolate(x))

# For comparison purposes
transform(df, x = locf(x))

}
\seealso{
Other fill functions: \code{\link{locf}},
  \code{\link{stretch}}
}
\concept{fill functions}
